<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'GET':
                break;
            case'POST':
                return [
                    'phone'=>'required|regex:/^1[3456789]\d{9}$/|unique:users,phone',
                    'password'=>'required|between:8,20|confirmed'
                ];
                break;
        }

    }
}
